import React from 'react'
import { ConfigProvider} from "antd";
import zhCN from 'antd/es/locale/zh_CN'
import { HashRouter as Router, Route, Redirect, Switch} from "react-router-dom";
import { render} from "react-dom";
import { Provider} from 'react-redux'
import store from './store'
import { mainRouter} from "./routes";
import App from "./app";
import User from './user'

render(
    <Provider store={store}>
        <ConfigProvider locale={zhCN}>
            <Router>
                <Switch>
                    <Route path='/admin' render={props => {
                        return <App {...props}></App>
                    }}>
                    </Route>
                    <Route path='/user' render={props => {
                        return <User {...props}></User>
                    }}>

                    </Route>
                    {
                        mainRouter.map(item => {
                            return <Route path={item.pathname} key={item.pathname} component={item.component} exact></Route>
                        })
                    }
                    <Redirect to='/login' from='/' exact></Redirect>
                    <Redirect to='/404'></Redirect>
                </Switch>
            </Router>
        </ConfigProvider>
    </Provider>
    ,
    document.querySelector('#root')
)